package com.probox.modules.controller.supplier;

import com.probox.common.core.web.controller.BaseController;
import com.probox.common.core.web.domain.AjaxResult;
import com.probox.common.core.web.page.TableDataInfo;
import com.probox.common.log.annotation.Log;
import com.probox.common.log.enums.BusinessType;
import com.probox.common.security.annotation.PreAuthorize;
import com.probox.common.entity.domain.supplier.vo.SysUserVo;
import com.probox.common.entity.service.supplier.ISysUserService;
import com.probox.systemApi.domain.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 账号管理Controller
 *
 * @author usoft
 * @date 2021-05-28
 */
@RestController
@RequestMapping("/supplier/account")
public class SupplierSysUserController extends BaseController {
    @Autowired
    private ISysUserService sysUserService;

    /**
     * 查询账号管理列表
     */
    @PreAuthorize(hasPermi = "supplier:account:list")
    @GetMapping("/list")
    public TableDataInfo list(SysUser sysUser) {
        startPage();
        List<SysUserVo> list = sysUserService.queryList(sysUser);
        TableDataInfo dataTable = null;
        if (list!=null){
            dataTable = getDataTable(list);
        }
        return dataTable;
    }

//    /**
//     * 导出账号管理列表
//     */
//    @PreAuthorize(hasPermi = "supplier:account:export")
//    @Log(title = "账号管理", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, SysUser sysUser) throws IOException
//    {
//        List<SysUser> list = sysUserService.queryList(sysUser);
//        ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
//        util.exportExcel(response, list, "账号管理数据");
//    }
//
//    /**
//     * 获取账号管理详细信息
//     */
//    @PreAuthorize(hasPermi = "supplier:account:query")
//    @GetMapping(value = "/{userId}")
//    public AjaxResult getInfo(@PathVariable("userId") Long userId)
//    {
//        return AjaxResult.success(sysUserService.selectSysUserById(userId));
//    }
//

    /**
     * 新增账号管理
     */
    @PreAuthorize(hasPermi = "supplier:account:add")
    @Log(title = "账号管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysUser sysUser) {
        return toAjax(sysUserService.insertSysUser(sysUser));
    }

    /**
     * 修改账号管理
     */
    @PreAuthorize(hasPermi = "supplier:account:edit")
    @Log(title = "账号管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysUser sysUser) {
        return toAjax(sysUserService.updateSysUser(sysUser));
    }
//
//    /**
//     * 删除账号管理
//     */
//    @PreAuthorize(hasPermi = "supplier:account:remove")
//    @Log(title = "账号管理", businessType = BusinessType.DELETE)
//    @DeleteMapping("/{userIds}")
//    public AjaxResult remove(@PathVariable Long[] userIds)
//    {
//        return toAjax(sysUserService.deleteSysUserByIds(userIds));
//    }
}
